<include file="../Public/_header.html" />
<div class="so_main">
	
	<!-------- 搜索开始 -------->
		  <div id="search_div">
		  	<div class="page_tit">
		  		搜索价格 [ <a href="javascript:void(0);" onclick="_show_searcharea();">隐藏</a> ]
		  	</div>
		
				<div class="sform">
					<form method="post" action="{:U('/Price/index')}" id="searchForm">
						<input id="pno" name="pno" type="hidden" value="1">
						<dl>
							<php>if(!empty($goods_id))$partner_id=getParnterIdByGoodsId($goods_id);</php>
					      	<span>选择商户：</span>
					        <input id="partnerdesc" type="text" value="{:getParnterTitle($partner_id)}"
					        onclick="k_pop_syncSearch('partner_id'
					        													,'partnerdesc'
					        													,'选择商户'
					        													,'{:U('Admin://Partner/getJson')}'
					        													,function(){ $('#goodsdesc').click(); }
					        													,function(){ $('#goodsdesc').val('');$('#goods_id').val(''); })" 
					        readonly >
					        <input name="partner_id" id="partner_id" type="hidden" value="{$partner_id}">

					      	<span>选择商品：</span>
					        <input id="goodsdesc" type="text" value="{:getGoodsTitle($goods_id)}"
					        onclick="k_pop_syncSearch('goods_id'
					        													,'goodsdesc'
					        													,'选择商品'
					        													,'{:U('Admin://Goods/getJson',array('partner_id'=>''))}'+$('#partner_id').val()
					        													,null
					        													,null)" 
					        readonly >
					        <input name="goods_id" id="goods_id" type="hidden" value="{$goods_id}">
					      
							<span>是否有效：</span>
					      	<input name="enable" type="radio" value="all" <eq name="enable" value="all">checked</eq>>全部
					        <input name="enable" type="radio" value="Y" <eq name="enable" value="Y">checked</eq>>是
					        <input name="enable" type="radio" value="N" <eq name="enable" value="N">checked</eq>>否
					    	<span>&nbsp;&nbsp;&nbsp;</span>
					    	<input type="submit" class="btn_b" value="提交" />
					    </dl>
					</form>
			  </div>
		  </div>
		  <!-------- 搜索结束 -------->
	
	
  <div class="page_tit">价格管理</div>
  <div class="Toolbar_inbox">
  	<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
		<span>条件搜索</span>
		</a>
  	<a href="{:U('Admin://Price/add')}" class="btn_a"><span>添加价格</span></a>
    <a href="javascript:void(0);" class="btn_a" onclick="del();"><span>删除价格</span></a>
  </div>
  
  <div class="list">
  <table id="price_list" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
        <input type="checkbox" id="checkbox_handle" onclick="table_checkAll(this)" value="0">
        <label for="checkbox"></label>
    </th>
    <th class="line_l" style="text-align:center"
    	 	title="户、品、价：对应商户、商品、价格，表示其各自是否有效。E代表对应数据为空。">户&nbsp;品&nbsp;价</th>
    <th class="line_l" style="text-align:center"
    		title="已售完：当进货量与卖出量相等，则表明该进货价商品已售完！销售中：当进货量与卖出量不相等，并且是否有效（enable=Y），表明该进货价的商品在销售中。暂停售：当进货量与卖出量不相等，并且是否有效（enable=N），表明该价格的进货暂时不能销售。"
    		>状态</th>
    <th class="line_l">商户</th>
    <th class="line_l">商品</th>
    <th class="line_l" style="text-align:center">销售开始</th>
    <th class="line_l" style="text-align:center">销售截止</th>
    <th class="line_l" style="text-align:right">市场价</th>
    <th class="line_l" style="text-align:right">进货价</th>
    <th class="line_l" style="text-align:right">进货量</th>
    <th class="line_l" style="text-align:right">卖出量</th>
    <th class="line_l" style="text-align:right">剩余量</th>
    <th class="line_l" style="text-align:center">操作</th>
  </tr>
  <volist id="vo" name="pagedata['data']">
  		<php>$partner_id=getParnterIdByGoodsId($vo['goods_id']);</php>
      <tr overstyle='on' id="price_{$vo.id}">
        <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="table_checkon(this)" value="{$vo.id}"></td>
        <td style="text-align:center;padding: 6px 0 6px 0px;color:red">
        	{:getParnterEnable($partner_id)}&nbsp;&nbsp;{:getGoodsEnable($vo['goods_id'])}&nbsp;&nbsp;{$vo['enable']}</td>
        
        <td style="text-align:center;padding: 6px 0 6px 0px;">
	        	<span style="color:red">
	        		<php>	if( $vo['total_number']==$vo['send_number'] ){ echo "已售完"; }
	        					else{ 
	        						if( $vo['enable']=='Y' ){echo "销售中"; }
	        						else { echo "暂停售"; }
	        					}</php></span>
        </td>
        
        <td>
        		
	        	<a href="{:U('/Partner/index',array('parent_id'=>$partner_id))}" 
	        		id="price_title_{$vo.id}">{$vo['goods_id']|getParnterTitleByGoodsId}</a>
        </td>
        
        <td>
	        	<a href="{:U('/Price/index',array('goods_id'=>$vo['goods_id']))}">
	        		{$vo['goods_id']|getGoodsTitle}</a>
        </td>
        <td style="text-align:center">
	        	<span>{:paramMillisecond2Date($vo['start_time'],'Y-m-d')}</span>
        </td>
        
        <td style="text-align:center">
	        	<span>{:paramMillisecond2Date($vo['expire_time'],'Y-m-d')}</span>
        </td>
        
        <td style="text-align:right">
	        	<span>
	        		{$vo['market_price']}</span>
        </td>
        
        <td style="text-align:right">
	        	<span>{$vo['in_price']}</span>
        </td>
        
        <td style="text-align:right">
	        	<span>{$vo['total_number']}</span>
        </td>
        <td style="text-align:right">
	        	<span>{$vo['send_number']}</span>
        </td>
        
        <td style="text-align:right">
	        	<span><php> echo $vo['total_number']-$vo['send_number'];</php></span>
        </td>
        
        <td  style="text-align:center">
            <a href="javascript:editPrice('{:U('/Price/editPrice',array('priceId'=>$vo['id']))}')" >编辑</a>&nbsp;&nbsp;
            <a href="javascript:void(0);" onclick="del({$vo['id']});">删除</a>  
        </td>
      </tr>
  </volist>
  </table>

  </div>
  <div class="Toolbar_inbox">
  	<div class="page_box">{$pagedata['html']}</div>
  </div>

</div>
  <div class="clear"></div>
<script>
	  //添加分类
    function editPrice(url) {
        ui.box.load(url, {title:'编辑价格'});
    }
	
    //鼠标移动表格效果
    $(document).ready(function(){
    	table_init();
    });
    
    
    //删除分类
    function del(aid) {
        aid = aid ? aid : table_getChecked();
        aid = aid.toString();
        if(aid == '') return false;
				if(!confirm('确定删除么？')){
						return;
				}
        //提交删除
        $.post("{:U('/Price/doDeletePrice')}", {ids:aid}, function(res){
	        if(res == '1') {
		        aid = aid.split(',');
		        $.each(aid, function(i,n){
		            $('#price_'+n).remove();
		        });
	            ui.success('删除成功');
	        }else {
	        	ui.success('删除失败');
	        }
        });
        
        
    }
</script>

<include file="../Public/_footer.html" />